package com.liao.badminton.dto;

import com.liao.badminton.code.BaseField;
import com.liao.badminton.code.validation.Delete;
import com.liao.badminton.code.validation.Insert;
import com.liao.badminton.code.validation.Update;
import io.swagger.annotations.ApiModelProperty;
import com.liao.badminton.entity.SystemUsers;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
import java.util.List;

import lombok.Data;
import com.liao.badminton.code.validation.FindDetail;

/**
 * @author liaocheng
 * @date 2024-10-30
 * description:用户信息表
 */
@Data
public class SystemUsersDto extends BaseField {

    @ApiModelProperty(value = "用户ID")
    @NotNull(message = "主键id不能为空", groups = {Delete.class, Update.class})
    private Long id;
    @Pattern(regexp = "^[a-zA-Z0-9_-]{4,16}$", message = "用户名必须为4-16位字母数字下划线", groups = {Insert.class, Update.class})
    @ApiModelProperty(value = "用户账号")
    private String username;
    @ApiModelProperty(value = "用户分享码")
    private String userCode;
    @NotNull(message = "密码不能为空", groups = {Insert.class})
    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "用户昵称")
    private String nickname;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "部门ID")
    private Long deptId;

    @ApiModelProperty(value = "岗位编号数组")
    private String postIds;

    @ApiModelProperty(value = "用户邮箱")
    private String email;

    @ApiModelProperty(value = "手机号码")
    private String mobile;

    @ApiModelProperty(value = "用户性别")
    private Integer sex;

    @ApiModelProperty(value = "头像地址")
    private String avatar;

    @ApiModelProperty(value = "帐号状态（0正常 1停用）")
    private Integer status;

    @ApiModelProperty(value = "最后登录IP")
    private String loginIp;

    @ApiModelProperty(value = "最后登录时间")
    private Date loginDate;

    private List<Long> delIds;  //批量删除ids

    @ApiModelProperty(value = "用户类型（0系统用户 1普通用户）")
    private Integer userType;

    @ApiModelProperty(value = "是否建群:0否 1是")
    private Integer newGroup=0;
    @ApiModelProperty(value = "群名")
    private String groupName;
    @ApiModelProperty(value = "所属群分享码,填了群分享码最好填群名称，不然可能对不以后对战数据")
    private String groupCode;
    private String groupMemberName;

    public SystemUsers invertEntity() {
        SystemUsers dto = new SystemUsers();
        BaseField.invert(this, dto);
        dto.setId(this.getId());
        dto.setUsername(this.getUsername());
        dto.setUserCode(this.getUserCode());
        dto.setPassword(this.getPassword());
        dto.setNickname(this.getNickname());
        dto.setRemark(this.getRemark());
        dto.setDeptId(this.getDeptId());
        dto.setPostIds(this.getPostIds());
        dto.setEmail(this.getEmail());
        dto.setMobile(this.getMobile());
        dto.setSex(this.getSex());
        dto.setAvatar(this.getAvatar());
        dto.setStatus(this.getStatus());
        dto.setLoginIp(this.getLoginIp());
        dto.setLoginDate(this.getLoginDate());
        dto.setUserType(this.getUserType());
        return dto;
    }
}
